#coding:gb2312

import logging
import sys,logging
default_encoding = 'utf-8'
if sys.getdefaultencoding() != default_encoding:
    reload(sys)
    sys.setdefaultencoding(default_encoding)

import os, re

microblogs = {}

def load_files(arg, dirname, names):
    spliter = re.compile(r"([^_]+.*[^_]?)\.py$")

    for name in names:
        if spliter.match(name.lower()):
    		modname = spliter.search(name.lower()).group(1)

	        obj = __import__( "updaters." + modname )
	        obj = eval ( "obj." + modname )
	        logging.info( "loaded obj." + modname )
	        serviceprovider = obj.__serviceprovider__
	        microblogs[ serviceprovider ] = obj

os.path.walk( "updaters", load_files, ())


aa ="""
########################################
# only in Google AppEngine
from google.appengine.api import memcache
data = memcache.get("updaters")
if data is not None:
	microblogs = data
else:
	os.path.walk( "updaters", load_files, ()) #all plantform
	memcache.add( "updaters", microblogs, 9876 )
#######################################
import follow5
import renren

microblogs = {}
microblogs[ "follow5" ] = follow5
microblogs[ "renren" ] = renren
"""

